package ssw.game;

import ssw.game.engine.GameDictionary;

public class GameType {
	public static final GameType TWO_LETTER_WORDS = new GameType(2, 2);
	public static final GameType TWO_LETTER_WORDS_THAT_YOU_CAN_ADD_S_TOO = new GameType(3, 3, Checks.STARTS_WITH_WORD, Checks.ENDS_WITH_AN_S);
	public static final GameType TWO_LETTER_ROOTS = new GameType(3, 3, Checks.STARTS_WITH_WORD);
	
	public int getNumberOfTiles()  {
		return 7;
	}
	
	private final int maxLengthOfWord;
	
	public int getMaxLengthOfWord()  {
		return maxLengthOfWord;
	}
	
	private final int minLengthOfWord;
	
	public int getMinLengthOfWord()  {
		return minLengthOfWord;
	}

	private final Checks[] checks;
	
	public boolean accept(String word, GameDictionary dictionary)  {
		if (minLengthOfWord > word.length())  {
			return false;
		}
		if (word.length() > maxLengthOfWord)  {
			return false;
		}
		
		for (Checks c : checks)  {
			if (!c.accept(word, dictionary))  {
				return false;
			}
		}
		
		return true;
	}
	
	private GameType(int min, int max, Checks... checks)  {
		super();
		minLengthOfWord = min;
		maxLengthOfWord = max;
		this.checks = checks;
	}
}
